﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Presentation
{
	public partial class Settings : Form
	{
		public Settings()
		{
			InitializeComponent();
		}

		public void SaveProperties()
		{
			generalSettings.SetProperties();
			renamingSettings.SetProperties();
			advancedSettings.SetProperties();

			Logic.Properties.Settings.Default.Save();
		}

		private void Settings_Load(object sender, EventArgs e)
		{
			generalSettings.Initialize();
			treeViewSections.ExpandAll();

			treeViewSections.SelectedNode = treeViewSections.Nodes[0];
		}

		private void treeViewSections_AfterSelect(object sender, TreeViewEventArgs e)
		{
			switch (e.Node.Name)
			{
				default:
				case "NodeGeneral":
					generalSettings.Visible = true;
					renamingSettings.Visible = false;
					advancedSettings.Visible = false;
					aboutSettings.Visible = false;

					generalSettings.BringToFront();
					break;
				case "NodeRenaming":
					generalSettings.Visible = false;
					renamingSettings.Visible = true;
					advancedSettings.Visible = false;
					aboutSettings.Visible = false;

					renamingSettings.BringToFront();
					break;
				case "NodeAdvanced":
					generalSettings.Visible = false;
					renamingSettings.Visible = false;
					advancedSettings.Visible = true;
					aboutSettings.Visible = false;

					advancedSettings.BringToFront();
					break;
				case "NodeAbout":
					generalSettings.Visible = false;
					renamingSettings.Visible = false;
					advancedSettings.Visible = false;
					aboutSettings.Visible = true;

					aboutSettings.BringToFront();
					break;
			}
		}

		private void buttonAccept_Click(object sender, EventArgs e)
		{
			SaveProperties();
			DialogResult = DialogResult.OK;
		}
	}
}